home *** CD-ROM | disk | FTP | other *** search
- head 1.2;
- branch ;
- access ;
- symbols ;
- locks ; strict;
- comment @ * @;
-
-
- 1.2
- date 90.09.11.14.46.43; author kupfer; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 90.09.06.17.31.52; author kupfer; state Exp;
- branches ;
- next ;
-
-
- desc
- @Determine if IEEE floating point number is infinite.
- @
-
-
- 1.2
- log
- @Use function prototypes.
- @
- text
- @/*
- * isinf.c --
- *
- * Machine-dependent procedure to determine whether a double is
- * infinity.
- *
- * Copyright 1989 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/etc/ds3100.md/RCS/isinf.c,v 1.1 90/09/06 17:31:52 kupfer Exp Locker: kupfer $ SPRITE (Berkeley)";
- #endif /* not lint */
-
- #include <math.h>
-
-
- /*
- *----------------------------------------------------------------------
- *
- * isinf --
- *
- * Return whether a double is equivalent to infinity.
- *
- * Results:
- * 1 if the number is infinity, 0 otherwise.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- int
- isinf(value)
- double value;
- {
- union {
- double d;
- long l[2];
- } u;
-
- /*
- * Put the value into a union so we can check out the bits.
- */
- u.d = value;
-
-
- /*
- * An IEEE Std 754 double precision floating point number
- * has the following format:
- *
- * 1 bit -- sign of Mantissa
- * 11 bits -- exponent
- * 52 bits -- Mantissa
- *
- * If the exponent has all bits set, the value is not a
- * real number.
- *
- * If the Mantissa is zero then the value is infinity, which
- * is the result of division by zero, or overflow.
- *
- * If the Mantissa is non-zero the value is not a number (NaN).
- * NaN can be generated by dividing zero by itself, taking the
- * logarithm of a negative number, etc.
- */
-
- /*
- * check the exponent
- */
- if ((u.l[1] & 0x7ff00000) == 0x7ff00000) {
-
- /*
- * See if the Mantissa is zero.
- */
- if ((u.l[1] & ~0xfff00000) == 0 && u.l[0] == 0) {
- /*
- * Infinity.
- */
- return (1);
- } else {
- /*
- * NaN.
- */
- return(0);
- }
- } else {
- /*
- * Normal.
- */
- return (0);
- }
- }
-
-
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d18 1
- a18 1
- static char rcsid[] = "$Header: /sprite/lib/forms/RCS/proto.c,v 1.2 89/01/07 04:12:18 rab Exp $ SPRITE (Berkeley)";
- d21 2
- d27 1
- a27 1
- * isnan --
- @
-